import { createStore } from 'vuex'
const store = createStore({
  state() {
    return {
      count: 0,
    }
  },
  mutations: {
    increment(state, payload = 1) {
      state.count += payload
    },
  },
  // 直接调用action,再去修改mutations，再去修改state
  actions: {
    incrementAction(context, payload) {
      setTimeout(() => {
        context.commit('increment', payload)
      }, 1000)
    },
  },
})
export default store
